package com.csweimei.rentmanagementtreasure.enterprise.viewModel;

import androidx.annotation.NonNull;
import androidx.databinding.ObservableArrayList;
import androidx.databinding.ObservableField;
import androidx.databinding.ObservableList;

import com.chad.library.BR;
import com.csweimei.rentmanagementtreasure.R;
import com.csweimei.rentmanagementtreasure.http.entity.CustomerCenterBean;

import me.goldze.mvvmhabit.base.BaseViewModel;
import me.goldze.mvvmhabit.base.MultiItemViewModel;
import me.tatarka.bindingcollectionadapter2.ItemBinding;

public class CCItemPVM extends MultiItemViewModel {
    public CCItemPVM(@NonNull BaseViewModel viewModel) {
        super(viewModel);
    }

    public ObservableField<CustomerCenterBean.DataDTO> bean = new ObservableField<>();


    public ObservableList<CCItemCVM>  observableList = new ObservableArrayList<>();
    public ItemBinding<CCItemCVM> itemBinding = ItemBinding.of(BR.viewModel, R.layout.item_customer_ent_child);

    public void setData(CustomerCenterBean.DataDTO data) {
        bean.set(data);

        for (CustomerCenterBean.DataDTO.CListDTO d : data.getCList()) {
            CCItemCVM ccItemCVM = new CCItemCVM(viewModel);
            ccItemCVM.setData(d);
            observableList.add(ccItemCVM);
        }

    }
}
